package week8;

import java.util.Iterator;

public class HeapSortTest {
    public static void main(String[] args) {
        Object[] data = {36,30,18,40,32,45,22,50};

       ArrayMaxHeap temp = new ArrayMaxHeap();
        for(int x = 0; x < data.length; x++){
            temp.addElement(data[x]);
        }

        Iterator c = temp.iteratorLevelOrder();
        System.out.println("层序输出：");
        while (c.hasNext())
        {
            System.out.print(c.next() + " ");
        }
        System.out.println();

        System.out.println("输出每轮排序的结果:");
        for (int a=0;a<data.length;a++)
        {
            data[a]=temp.removeMax();
            String result1="";
            for (int x=0;x<=a;x++){
                result1+=data[x]+" ";
            }
            Iterator d = temp.iteratorLevelOrder();
            while (d.hasNext()){
                result1+=d.next()+" ";
            }
            System.out.println("第"+(a+1)+"轮："+result1);

        }
    }
}
